home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 65.zip / BS1 part 65 / Art Department Pro 2.15 d2.adf / RXProgs.lzh / scaletoaspect.adpro < prev    next >
Text File  |  1991-10-29  |  1KB  |  69 lines

  1. /* 
  2. ** This ARexx program allows the user to input a desired pixel
  3. ** aspect. The image will be scaled UP (if possible) to acheive
  4. ** this goal. If the UP scale fails, then it will attempt
  5. ** to scale down.
  6. **
  7. ** Copyright 1991 By  ASDG Incorporated
  8. */
  9.  
  10. OPTIONS RESULTS
  11.  
  12. ADDRESS "ADPro"
  13.  
  14. IMAGE_TYPE
  15. IF (ADPRO_RESULT = "NONE") | (ADPRO_RESULT = "BITPLANE") THEN DO
  16.     OKAY1 "No image data to scale."
  17.     EXIT
  18. END
  19.  
  20. OPERATOR DEFINE_PXL_ASPECT
  21. IF RC ~= 0 THEN EXIT
  22.  
  23. xaspect = WORD(ADPRO_RESULT, 1)
  24. yaspect = WORD(ADPRO_RESULT, 2)
  25.  
  26. GETNUMBER '"Enter Desired X-Aspect"' 1 1 240
  27. IF RC ~= 0 THEN EXIT
  28. dx = ADPRO_RESULT
  29.  
  30. GETNUMBER '"Enter Desired Y-Aspect"' 1 1 240
  31. dy = ADPRO_RESULT
  32. IF RC ~= 0 THEN EXIT
  33.  
  34. IF xaspect = dx and yaspect = dy THEN EXIT
  35. /* Always scale UP */
  36.  
  37. xfactor = (xaspect / yaspect) * 100
  38. yfactor = 100
  39. IF dx > dy THEN DO
  40.     xfactor = dx * 10000 / (dy * xfactor)
  41. END
  42. ELSE DO
  43.     xfactor = xfactor * (dy / dx)
  44. END
  45.  
  46. IF xfactor < 100 THEN DO
  47.     yfactor = 10000/xfactor
  48.     xfactor = 100
  49. END
  50.  
  51. PCT_SCALE TRUNC(xfactor+0.5) TRUNC(yfactor+0.5)
  52.  
  53. /* IF scale up failed, attempt scale down */
  54. IF RC ~= 0 THEN DO
  55.     OKAY2 "Scale up failed. Attemp scale down?"
  56.     IF RC = 0 THEN EXIT
  57.     PCT_SCALE TRUNC((10000/yfactor)+0.5) TRUNC((10000/xfactor)+0.5)
  58.     IF RC = 0 THEN DO 
  59.         OPERATOR DEFINE_PXL_ASPECT dx dy
  60.     END
  61. END
  62. ELSE DO
  63.     /* Set the pixel aspect, since SCALE does 
  64.     ** not do that when used from AREXX
  65.     */
  66.     OPERATOR DEFINE_PXL_ASPECT dx dy
  67. END
  68. EXIT
  69.